/**
 * Copyright (C) 2008-2009 Cristian Olaru <colaru@gmail.com>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *         http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.integrationpath.mengine.webapp.decorator;

import org.displaytag.decorator.TableDecorator;
import com.integrationpath.mengine.model.Comment;
import com.integrationpath.mengine.webapp.listener.StartupListener;
import com.integrationpath.mengine.webapp.util.EngineConstants;

public class CommentDecorator extends TableDecorator {

	String response = "";
	Comment message;
	
	public CommentDecorator() {		
	}
	
	public String getAdminState() {
		Comment comment = (Comment)getCurrentRowObject();
		switch (comment.getStatus()) {
		case EngineConstants.ARTICLE_ENABLED:
			response = "<a id='image" + comment.getId() + "' onclick='changeCommentStatusCode(" + comment.getId() + "," + comment.getStatus() + ")'><img alt='ENABLED' src='" + StartupListener.getAppContext().getAttribute("path_theme") + "/images/available.png'/><a/>";
			break;
		case EngineConstants.ARTICLE_DISABLED:
			response = "<a id='image" + comment.getId() + "' onclick='changeCommentStatusCode(" + comment.getId() + "," + comment.getStatus() +  ")'><img alt='DISABLED' src='" + StartupListener.getAppContext().getAttribute("path_theme") + "/images/unavailable.png'/><a/>";
			break;
		}	
		return response;
	}
	
	public String getComContent() {
		Comment comment = (Comment)getCurrentRowObject();
		return comment.getContent().substring(8);
	}
	
}
